package security

import play.api.libs.json.JsValue

object Checked {
  def isCharOfPassword(string: String):Boolean = {
    val pattern = "[^a-zA-Z0-9]".r
    val p_num = "[0-9]".r
    val p_char = "[a-zA-Z]".r
    pattern.findFirstIn(string).isEmpty&&p_num.findFirstIn(string).nonEmpty&&p_char.findFirstIn(string).nonEmpty
  }

  def isCharOfName(string: String):Boolean = {
    val pattern = "[^a-zA-Z0-9_]".r
    pattern.findFirstIn(string).isEmpty
  }

  def asString(v: JsValue) = v.asOpt[String].getOrElse(v.toString)

}
